package com.codelazy.desetalk;
import com.desetalk.proto.ResponseProtocol.Response;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.content.LocalBroadcastManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.webkit.WebView.FindListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class RankFragment extends Fragment {
	private Button btn_info;
	private BroadcastReceiver mMessageReceiver;
	private Response response;
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		return inflater.inflate(R.layout.fragment_rank, container, false);
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		btn_info = (Button) getView().findViewById(R.id.btn_info);
		btn_info.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Toast.makeText(getActivity(),"点击成功",
						Toast.LENGTH_SHORT).show();
				Intent intent = new Intent("local_sender");
				// You can also include some extra data.
				intent.putExtra("message", "enterLobby 30");
				LocalBroadcastManager.getInstance(getActivity())
						.sendBroadcast(intent);
			}
		});
		mMessageReceiver = new BroadcastReceiver() {
			@Override
			public void onReceive(Context context, Intent intent) {
				// Get extra data included in the Intent
				String message = intent.getStringExtra("message");
				//tv.setText(message);
			}
		};
		LocalBroadcastManager.getInstance(getActivity()).registerReceiver(
				mMessageReceiver, new IntentFilter("local_receiver"));
	}
}
